package org.agile2soft.nexoma.expedient.entities;


import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "EXPEDIENT_TYPE")
@SuppressWarnings({"serial"})
public class ExpedientType implements java.io.Serializable {

    private Integer id;
    private String name;
    private boolean queries;
    private boolean endNoValidated;
    private boolean webAvailable;
    private byte[] diagram;
    private String comments;
    private Set<Document> documents = new HashSet<Document>(0);
    private Set<ExpedientTypePhase> expedientTypePhases = new HashSet<ExpedientTypePhase>(0);
    private Set<Expedient> expedients = new HashSet<Expedient>(0);
    private Set<ExpedientTypePhaseExpedients> expedientTypePhaseExpedients = new HashSet<ExpedientTypePhaseExpedients>(0);

    public ExpedientType() {
    }

    public ExpedientType(String name, boolean queries,
            boolean endValidated, boolean webAvailable) {
        this.name = name;
        this.queries = queries;
        this.endNoValidated = endValidated;
        this.webAvailable = webAvailable;
    }

    public ExpedientType(String name, boolean queries,
            boolean endValidated, boolean webAvailable,
            byte[] diagram, String comments,
            Set<Document> documents,
            Set<ExpedientTypePhase> tExpedientPhases,
            Set<Expedient> expedients,
            Set<ExpedientTypePhaseExpedients>expedientTypePhaseExpedients) {
        this.name = name;
        this.queries = queries;
        this.endNoValidated = endValidated;
        this.webAvailable = webAvailable;
        this.diagram = diagram;
        this.comments = comments;
        this.documents = documents;
        this.expedientTypePhases = tExpedientPhases;
        this.expedients = expedients;
        this.expedientTypePhaseExpedients = expedientTypePhaseExpedients;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "TEX_ID", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "TEX_NAME", nullable = false, length = 70)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "TEX_QUERIES", nullable = false)
    public boolean isQueries() {
        return this.queries;
    }

    public void setQueries(boolean queries) {
        this.queries = queries;
    }

    @Column(name = "TEX_END_NO_VALIDATED", nullable = false)
    public boolean isEndNoValidated() {
        return this.endNoValidated;
    }

    public void setEndNoValidated(boolean endNoValidated) {
        this.endNoValidated = endNoValidated;
    }

    @Column(name = "TEX_WEB_AVAILABLE", nullable = false)
    public boolean isWebAvailable() {
        return this.webAvailable;
    }

    public void setWebAvailable(boolean webAvailable) {
        this.webAvailable = webAvailable;
    }

    @Column(name = "TEX_DIAGRAM")
    public byte[] getDiagram() {
        return this.diagram;
    }

    public void setDiagram(byte[] diagram) {
        this.diagram = diagram;
    }

    @Column(name = "TEX_COMMENTS", length = 150)
    public String getComments() {
        return this.comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "expedient_type_document", joinColumns = { @JoinColumn(name = "TEX_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "DOCU_ID", nullable = false, updatable = false) })
    public Set<Document> getDocuments() {
        return this.documents;
    }

    public void setDocuments(Set<Document> documents) {
        this.documents = documents;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "expedientType")
    public Set<ExpedientTypePhase> getExpedientTypePhases() {
        return this.expedientTypePhases;
    }

    public void setExpedientTypePhases(
            Set<ExpedientTypePhase> expedientTypePhases) {
        this.expedientTypePhases = expedientTypePhases;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "expedientType")
    public Set<Expedient> getExpedients() {
        return this.expedients;
    }

    public void setExpedients(Set<Expedient> expedients) {
        this.expedients = expedients;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "expedientType")
    public Set<ExpedientTypePhaseExpedients> getExpedientTypePhaseExpedients() {
        return this.expedientTypePhaseExpedients;
    }

    public void setExpedientTypePhaseExpedients(Set<ExpedientTypePhaseExpedients> expedientTypePhaseExpedients) {
        this.expedientTypePhaseExpedients = expedientTypePhaseExpedients;
    }
}
